﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using YawetagDemo.Framework.Data;

namespace YawetagDemo.Framework.Server.Data
{
    [DataContract(IsReference = true)]
    public class WCFPerson : IPerson
    {
        private WCFPerson(IPerson person, IDictionary<object, object> references)
        {
            references.Add(person, this);

            PersonID = person.PersonID;

            Name = person.Name;
            DOB = person.DOB;
            Age = person.Age;
        }

        public static WCFPerson Get(IPerson person, IDictionary<object, object> references)
        {
            return (WCFPerson)(references.ContainsKey(person) ? references[person] : new WCFPerson(person, references));
        }

        [DataMember] public int PersonID { get; private set; }

        [DataMember] public string Name { get; private set; }
        [DataMember] public DateTime? DOB { get; private set; }
        [DataMember] public int? Age { get; private set; }
    }
}
